/**
 * 添加或编辑
 */
function saveAndEdit() {

    var name = $("#name").val();
    if(name === ""){
        alert("分类名称！")
        return;
    }

    var dicCode = $("#dicCode").val();
    if(dicCode === ""){
        alert("字典代码！")
        return;
    }

    var company = $("#company").val();
    if(company === ""){
        alert("所属系统！")
        return;
    }

    var notes = $("#notes").val();
    if(notes === ""){
        alert("备注！")
        return;
    }

    // 结构类型
    var type = $("#type").val();

    // id
    var id = $("#id").val();

    $.ajax({
        url: "/dictionary/saveAndEdit",
        type: "POST",
        data: {
            'name': name,
            'dicCode': dicCode,
            'company': company,
            'notes': notes,
            'type': type,
            'id': id
        },
        dataType: "json",
        async: false,
        success: function (data) {
            if (data.code === '200') {
                alert("操作成功！")
                window.location.href = "/dictionary/list";
            } else {
                alert(data.msg)
            }
        },
        error: function (e) {
            alert("操作失败！")
            console.log(e)
        }
    })
}

function cancel() {
    window.history.back();
}

